{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 什么是Alpha101?\n",
    "*用数学公式找到Alpha机会*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 目录\n",
    "\n",
    "1. Alpha101是什么？\n",
    "2. Alpha101用到的算法有哪些？\n",
    "3. Alpha001-010怎么写？\n",
    "4. 用柱图展示因子绩效\n",
    "5. 如何用TA_Lib设计新的Alpha因子？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Alpha101是什么？\n",
    "WorldQuant根据数据挖掘的方法发掘了101个alpha，据说里面 80% 的因子仍然还行之有效并运行在他们的投资策略中。Alpha101给出的公式，也就是计算机代码101年真实的定量交易Alpha。他们的平均持有期大约范围0.6 - 6.4天。平均两两这些Alpha的相关性较低,为15.9%。回报是与波动强相关，但对换手率没有明显的依赖性，直接确认较早的间接经验分析结果。我们从经验上进一步发现换手率对alpha相关性的解释能力很差。\n",
    "\n",
    "PDF下载：\n",
    "\n",
    "Python代码下载：## Alpha101主要元素有什么？\n",
    "### 1. 因子组成元素\n",
    "- 价量因子（52/101）：\n",
    "    - HLOC\n",
    "    - ADV\n",
    "    - VWAP\n",
    "    - Volume\n",
    "- 价格波动因子（21/101）:\n",
    "    - HLOC\n",
    "    - Return\n",
    "    - STD()\n",
    "- 组合因子(8/101): 价量与价波因子组合\n",
    "- 市值因子（1/101）:\n",
    "    - Return\n",
    "    - Cap\n",
    "- 板块组合因子（19/101）: 板块分类结合价量与价波因子\n",
    "\n",
    "### 2. 函数与运算符\n",
    "- 'x?y:z'是指x为True，返回y，否则返回z。\n",
    "- Rank是指横向的品种间排序。\n",
    "- ts_Rank是指纵向的时间序列排序。\n",
    "\n",
    "详细参考原文PDF"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Alpha101用到的算法有哪些？\n",
    "### Step1 编制函数需要的算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 1. 编制函数需要的算法，\n",
    "#coding=utf-8\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from scipy.stats import rankdata\n",
    "\n",
    "# 计算alpha101时会使用的函数\n",
    "# 移动求和\n",
    "def ts_sum(df,window=10):\n",
    "    return df.rolling(window).sum()\n",
    "\n",
    "#移动平均\n",
    "def ts_mean(df,window=10):\n",
    "    return df.rolling(window).mean()\n",
    "\n",
    "#移动标准差\n",
    "def stddev(df,window=10):\n",
    "    return df.rolling(window).std()\n",
    "\n",
    "#移动相关系数\n",
    "def correlation(x,y,window=10):\n",
    "    return x.rolling(window).corr(y)\n",
    "\n",
    "#移动协方差\n",
    "def covariance(x,y,window=10):\n",
    "    return x.rolling(window).cov(y)\n",
    "\n",
    "\n",
    "def rolling_rank(na):\n",
    "    return rankdata(na)[-1]\n",
    "\n",
    "#移动排序\n",
    "def ts_rank(df, window=10):\n",
    "    return df.rolling(window).apply(rolling_rank)\n",
    "\n",
    "def rolling_prod(na):\n",
    "    return na.prod(na)\n",
    "\n",
    "#移动乘积\n",
    "def product(df,window=10):\n",
    "    return df.rolling(window).apply(rolling_prod)\n",
    "\n",
    "# 移动窗口最小值\n",
    "def ts_min(df,window=10):\n",
    "    return df.rolling(window).min()\n",
    "\n",
    "# 移动窗口最大值\n",
    "def ts_max(df,window=10):\n",
    "    return df.rolling(window).max()\n",
    "\n",
    "# 差值\n",
    "def delta(df,period=1):\n",
    "    return df.diff(period)\n",
    "\n",
    "# 位移\n",
    "def delay(df,period=1):\n",
    "    return df.shift(period)\n",
    "\n",
    "# 横向排序\n",
    "def rank(df):\n",
    "    return df.rank(axis=1, pct=True)\n",
    "\n",
    "# 数值规模\n",
    "def scale(df,k=1):\n",
    "    return df.mul(k).div(np.abs(df).sum())\n",
    "\n",
    "# 最大值的坐标\n",
    "def ts_argmax(df,window=10):\n",
    "    return df.rolling(window).apply(np.argmax)+1\n",
    "\n",
    "# 最小值的坐标\n",
    "def ts_argmin(df,window=10):\n",
    "    return df.rolling(window).apply(np.argmin)+1\n",
    "\n",
    "# 加权平均\n",
    "def decay_linear(df,period=10):\n",
    "    if df.isnull().values.any():\n",
    "        df.fillna(method='ffill',inplace=True)\n",
    "        df.fillna(method='bfill',inplace=True)\n",
    "        df.fillna(value=0, inplace=True)\n",
    "    return pd.DataFrame(\n",
    "        {name: ta.WMA(item.values, period) for name, item in df.iteritems()},\n",
    "        index=df.index\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 2. 定义计算alpha值的类\n",
    "class alphas(object):\n",
    "    def __init__(self, pn_data):\n",
    "        \"\"\"\n",
    "        :传入参数 pn_data: pandas.Panel\n",
    "        \"\"\"\n",
    "        # 获取历史数据\n",
    "        self.open = pd.DataFrame(pn_data.minor_xs('open'), dtype=np.float64)\n",
    "        self.high = pd.DataFrame(pn_data.minor_xs('high'), dtype=np.float64)\n",
    "        self.low = pd.DataFrame(pn_data.minor_xs('low'), dtype=np.float64)\n",
    "        self.close = pd.DataFrame(pn_data.minor_xs('close'), dtype=np.float64)\n",
    "        self.volume = pd.DataFrame(pn_data.minor_xs('volume'), dtype=np.float64)\n",
    "        self.returns = pd.DataFrame(self.close.pct_change())\n",
    "        self.adv = ts_mean(self.volume, 10)\n",
    "        self.vwap = ts_sum(self.close*self.volume, 10)/ts_sum(self.volume, 10)\n",
    "\n",
    "# 3. 编制因子的函数\n",
    "    \n",
    "    #   alpha001:(rank(Ts_ArgMax(SignedPower(((returns < 0) ? stddev(returns, 20) : close), 2.), 5)) -0.5)\n",
    "    def alpha001(self):\n",
    "        inner = self.close\n",
    "        inner[self.returns < 0] = stddev(self.returns, 20)\n",
    "        alpha = rank(ts_argmax(inner ** 2, 5))\n",
    "        return alpha\n",
    "    \n",
    "    #  alpha002:(-1 * correlation(rank(delta(log(volume), 2)), rank(((close - open) / open)), 6))\n",
    "    def alpha002(self):\n",
    "        alpha = -1 * correlation(rank(delta(np.log(self.volume), 2)), rank((self.close - self.open) / self.open), 6)\n",
    "        return alpha.replace([-np.inf, np.inf], np.nan)\n",
    "\n",
    "    # alpha003:(-1 * correlation(rank(open), rank(volume), 10))\n",
    "    def alpha003(self):\n",
    "        alpha = -1 * correlation(rank(self.open), rank(self.volume), 10)\n",
    "        return alpha.replace([-np.inf, np.inf], np.nan)\n",
    "\n",
    "    # alpha004: (-1 * Ts_Rank(rank(low), 9))\n",
    "    def alpha004(self):\n",
    "        alpha = -1 * ts_rank(rank(self.low), 9)\n",
    "        return alpha\n",
    "    \n",
    "    # alpha005:(rank((open - (sum(vwap, 10) / 10))) * (-1 * abs(rank((close - vwap)))))\n",
    "    def alpha005(self):\n",
    "        alpha = (rank((self.open - (ts_sum(self.vwap, 10) / 10))) * (-1 * np.abs(rank((self.close - self.vwap)))))\n",
    "        return alpha\n",
    "    \n",
    "    # alpha006: (-1 * correlation(open, volume, 10))\n",
    "    def alpha006(self):\n",
    "        alpha = -1 * correlation(self.open, self.volume, 10)\n",
    "        return alpha\n",
    "        \n",
    "    # alpha007: ((adv20 < volume) ? ((-1 * ts_rank(abs(delta(close, 7)), 60)) * sign(delta(close, 7))) : (-1* 1))\n",
    "    def alpha007(self):\n",
    "        adv20 = ts_mean(self.volume, 20)\n",
    "        alpha = -1 * ts_rank(abs(delta(self.close, 7)), 60) * np.sign(delta(self.close, 7))\n",
    "        alpha[adv20 >= self.volume] = -1\n",
    "        return alpha\n",
    "\n",
    "    # alpha008: (-1 * rank(((sum(open, 5) * sum(returns, 5)) - delay((sum(open, 5) * sum(returns, 5)),10))))\n",
    "    def alpha008(self):\n",
    "        alpha = -1 * (rank(((ts_sum(self.open, 5) * ts_sum(self.returns, 5)) -\n",
    "                          delay((ts_sum(self.open, 5) * ts_sum(self.returns, 5)), 10))))\n",
    "        return alpha\n",
    "    \n",
    "    # alpha009:((0 < ts_min(delta(close, 1), 5)) ? delta(close, 1) : ((ts_max(delta(close, 1), 5) < 0) ?delta(close, 1) : (-1 * delta(close, 1))))\n",
    "    def alpha009(self):\n",
    "        delta_close = delta(self.close, 1)\n",
    "        cond_1 = ts_min(delta_close, 5) > 0\n",
    "        cond_2 = ts_max(delta_close, 5) < 0\n",
    "        alpha = -1 * delta_close\n",
    "        alpha[cond_1 | cond_2] = delta_close\n",
    "        return alpha\n",
    "\n",
    "    # alpha010: rank(((0 < ts_min(delta(close, 1), 4)) ? delta(close, 1) : ((ts_max(delta(close, 1), 4) < 0)? delta(close, 1) : (-1 * delta(close, 1)))))\n",
    "    def alpha010(self):\n",
    "        delta_close = delta(self.close, 1)\n",
    "        cond_1 = ts_min(delta_close, 4) > 0\n",
    "        cond_2 = ts_max(delta_close, 4) < 0\n",
    "        alpha = -1 * delta_close\n",
    "        alpha[cond_1 | cond_2] = delta_close\n",
    "        return alpha"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step2 获取股票池"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('002230.XSHE', '002299.XSHE', '601225.XSHG', '002174.XSHE', '601727.XSHG', '600019.XSHG', '601127.XSHG', '002385.XSHE', '601216.XSHG', '300070.XSHE', '000709.XSHE', '002074.XSHE', '600074.XSHG', '000983.XSHE', '300133.XSHE', '300072.XSHE', '601118.XSHG', '300059.XSHE', '000826.XSHE', '300144.XSHE', '600867.XSHG', '300024.XSHE', '002131.XSHE', '002152.XSHE', '600188.XSHG', '600010.XSHG', '600009.XSHG', '000792.XSHE', '300002.XSHE', '600048.XSHG', '002739.XSHE', '300017.XSHE', '300033.XSHE', '000778.XSHE', '600271.XSHG', '300058.XSHE', '601258.XSHG', '601600.XSHG', '300251.XSHE', '000060.XSHE', '600383.XSHG', '600875.XSHG', '002146.XSHE', '600111.XSHG', '600256.XSHG', '601933.XSHG', '600873.XSHG', '600446.XSHG', '300027.XSHE', '000027.XSHE', '000425.XSHE', '600583.XSHG', '300168.XSHE', '002153.XSHE', '601021.XSHG', '000977.XSHE', '000555.XSHE', '000402.XSHE', '002183.XSHE', '600352.XSHG', '600157.XSHG', '000876.XSHE', '600582.XSHG', '601611.XSHG', '000800.XSHE', '000630.XSHE', '600718.XSHG', '000839.XSHE', '600196.XSHG', '601958.XSHG', '002202.XSHE', '600008.XSHG', '600606.XSHG', '600037.XSHG', '600637.XSHG', '002310.XSHE', '002292.XSHE', '600332.XSHG', '000712.XSHE', '600737.XSHG', '600068.XSHG', '600783.XSHG', '000718.XSHE', '000157.XSHE', '600208.XSHG', '601857.XSHG', '002500.XSHE', '600739.XSHG', '000415.XSHE', '600021.XSHG', '600150.XSHG', '000166.XSHE', '600369.XSHG', '002065.XSHE', '600252.XSHG', '601328.XSHG', '000963.XSHE', '600066.XSHG', '601718.XSHG', '002024.XSHE', '600570.XSHG', '600362.XSHG', '600518.XSHG', '600297.XSHG', '600649.XSHG', '000768.XSHE', '002081.XSHE', '002568.XSHE', '600340.XSHG', '600705.XSHG', '600038.XSHG', '600221.XSHG', '600827.XSHG', '601928.XSHG', '603000.XSHG', '601899.XSHG', '601866.XSHG', '600839.XSHG', '000917.XSHE', '002142.XSHE', '601390.XSHG', '000156.XSHE', '603993.XSHG', '600177.XSHG', '601800.XSHG', '002465.XSHE', '002466.XSHE', '600028.XSHG', '601186.XSHG', '002594.XSHE', '600018.XSHG', '600688.XSHG', '600016.XSHG', '601166.XSHG', '002797.XSHE', '000001.XSHE', '000738.XSHE', '000728.XSHE', '002736.XSHE', '600816.XSHG', '603885.XSHG', '600663.XSHG', '600685.XSHG', '601989.XSHG', '601919.XSHG', '601872.XSHG', '601618.XSHG', '601608.XSHG', '601377.XSHG', '601288.XSHG', '601099.XSHG', '601088.XSHG', '601018.XSHG', '601006.XSHG', '600959.XSHG', '600895.XSHG', '600886.XSHG', '600871.XSHG', '600795.XSHG', '600666.XSHG', '600654.XSHG', '600498.XSHG', '600489.XSHG', '600485.XSHG', '600415.XSHG', '600170.XSHG', '600115.XSHG', '600100.XSHG', '600050.XSHG', '300104.XSHE', '300085.XSHE', '002470.XSHE', '002426.XSHE', '002252.XSHE', '002129.XSHE', '002049.XSHE', '002027.XSHE', '000503.XSHE', '000100.XSHE', '000061.XSHE', '000008.XSHE', '601198.XSHG', '600958.XSHG', '601633.XSHG', '600376.XSHG', '000627.XSHE', '601669.XSHG', '601985.XSHG', '600585.XSHG', '600704.XSHG', '600754.XSHG', '601939.XSHG', '600804.XSHG', '000750.XSHE', '601398.XSHG', '600061.XSHG', '601766.XSHG', '600820.XSHG', '000895.XSHE', '601169.XSHG', '600893.XSHG', '601333.XSHG', '600549.XSHG', '601818.XSHG', '600900.XSHG', '601555.XSHG', '601009.XSHG', '601988.XSHG', '002673.XSHE', '000671.XSHE', '600023.XSHG', '000559.XSHE', '000793.XSHE', '000686.XSHE', '600372.XSHG', '600999.XSHG', '600547.XSHG', '601155.XSHG', '600535.XSHG', '001979.XSHE', '601998.XSHG', '000623.XSHE', '600588.XSHG', '600015.XSHG', '000540.XSHE', '601788.XSHG', '600674.XSHG', '300315.XSHE', '000009.XSHE', '600030.XSHG', '002007.XSHE', '600837.XSHG', '600406.XSHG', '002424.XSHE', '000776.XSHE', '600153.XSHG', '002714.XSHE', '600000.XSHG', '300146.XSHE', '600031.XSHG', '601877.XSHG', '000625.XSHE', '600118.XSHG', '600109.XSHG', '600060.XSHG', '000938.XSHE', '600104.XSHG', '002456.XSHE', '300182.XSHE', '300015.XSHE', '601688.XSHG', '000725.XSHE', '601628.XSHG', '600089.XSHG', '600276.XSHG', '601668.XSHG', '600029.XSHG', '000783.XSHE', '600482.XSHG', '601901.XSHG', '601211.XSHG', '000413.XSHE', '601888.XSHG', '600887.XSHG', '600309.XSHG', '600085.XSHG', '601111.XSHG', '600648.XSHG', '601318.XSHG', '000338.XSHE', '000002.XSHE', '600373.XSHG', '600036.XSHG', '000651.XSHE', '000039.XSHE', '002450.XSHE', '002304.XSHE', '601601.XSHG', '600660.XSHG', '000069.XSHE', '601336.XSHG', '002236.XSHE', '600519.XSHG', '000423.XSHE', '600741.XSHG', '002008.XSHE', '000538.XSHE', '601607.XSHG', '000333.XSHE', '000858.XSHE', '600690.XSHG', '002415.XSHE', '000568.XSHE', '002475.XSHE', '002195.XSHE', '300124.XSHE', '000063.XSHE', '002085.XSHE', '002241.XSHE', '600703.XSHG')\n"
     ]
    }
   ],
   "source": [
    "# 4. 传入股票池数据\n",
    "if __name__ == '__main__':\n",
    "    from fxdayu_data import DataAPI\n",
    "    from datetime import datetime\n",
    "    import tushare as ts\n",
    "    import numpy as np\n",
    "    import matplotlib.pyplot as plt\n",
    "    import pandas as pd\n",
    "    import alphalens\n",
    "    \n",
    "    #输入config的位置\n",
    "    DataAPI.set_file('D:/PycharmProjects/Quant_Alpha/Data_Manager/Factor_Selection/config.py')\n",
    "\n",
    "    #改名字的方法\n",
    "    def coder(code):\n",
    "        if code.startswith('6'):\n",
    "            return code + '.XSHG'\n",
    "        elif code.startswith('0') or code.startswith('3'):\n",
    "            return code + '.XSHE'\n",
    "        else:\n",
    "            return code\n",
    "    \n",
    "    #获取沪深300的股票名\n",
    "    name = ts.get_hs300s()\n",
    "    name_list = list(name.code)\n",
    "    codes = tuple(map(coder, name_list))\n",
    "    print(codes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step3 读取数据并计算IC值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.panel.Panel'>\n",
      "Dimensions: 300 (items) x 1077 (major_axis) x 5 (minor_axis)\n",
      "Items axis: 000001.XSHE to 603993.XSHG\n",
      "Major_axis axis: 2013-01-04 15:00:00 to 2017-06-13 15:00:00\n",
      "Minor_axis axis: close to volume\n"
     ]
    }
   ],
   "source": [
    "    PN = DataAPI.factor(codes, ('open', 'high', 'low', 'close', 'volume'), start=datetime(2013, 1, 1))\n",
    "    prices = PN.minor_xs('close')\n",
    "    print PN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             1         5         10\n",
      "seven  0.214916  0.230020  0.225757\n",
      "ten    0.382698  0.427790  0.418241\n",
      "nine   0.407941  0.453681  0.450126\n",
      "six    0.027573  0.033777  0.041094\n",
      "three  0.005634  0.010449  0.015037\n",
      "two    0.035391  0.034132  0.008091\n",
      "four   0.064523  0.065857  0.060070\n",
      "eight  0.112418  0.104459  0.086828\n",
      "five   0.301093  0.303139  0.299830\n",
      "one   -0.192433 -0.201775 -0.191760\n"
     ]
    }
   ],
   "source": [
    "    from collections import OrderedDict\n",
    "    \n",
    "    alpha = alphas(PN)\n",
    "    factors = {'one': alpha.alpha001(),\n",
    "               'two': alpha.alpha002(),\n",
    "               'three': alpha.alpha003(),\n",
    "               'four': alpha.alpha004(),\n",
    "               'five': alpha.alpha005(),\n",
    "               'six': alpha.alpha006(),\n",
    "               'seven': alpha.alpha007(),\n",
    "               'eight': alpha.alpha008(),\n",
    "               'nine': alpha.alpha009(),\n",
    "               'ten': alpha.alpha010()}\n",
    "\n",
    "\n",
    "    def cal_monthly_ic(factor):\n",
    "        factor_data = alphalens.utils.get_clean_factor_and_forward_returns(factor.stack(), prices, quantiles=5)\n",
    "        return alphalens.performance.mean_information_coefficient(factor_data, by_time='M')\n",
    "\n",
    "    monthly_ic = {key: cal_monthly_ic(value) for key, value in factors.items()}\n",
    "\n",
    "    monthly_ic_mean = pd.DataFrame(\n",
    "        map(lambda frame: frame.mean(), monthly_ic.values()),\n",
    "        monthly_ic.keys()\n",
    "    )\n",
    "    print monthly_ic_mean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             1         5         10\n",
      "seven  0.059689  0.062802  0.058519\n",
      "ten    0.070118  0.061659  0.084437\n",
      "nine   0.085144  0.078367  0.071449\n",
      "six    0.021528  0.024599  0.020430\n",
      "three  0.013544  0.016175  0.019742\n",
      "two    0.066674  0.082584  0.076191\n",
      "four   0.045066  0.031038  0.032137\n",
      "eight  0.045690  0.050938  0.046118\n",
      "five   0.085040  0.074704  0.048871\n",
      "one    0.042129  0.042742  0.042589\n"
     ]
    }
   ],
   "source": [
    "    monthly_ic_std = pd.DataFrame(\n",
    "        map(lambda frame: frame.std(), monthly_ic.values()),\n",
    "        monthly_ic.keys()\n",
    "    )\n",
    "    print monthly_ic_std"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step4 用柱图显示IC的均值与标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe4AAAFlCAYAAAAtYAtNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlAVOX6B/DvGQZMBBURFVcEFRDDEv2ZohfFpVy4hKag\nhVtqVJZLmaK5XE1LxUtqkguWZilooZFLXXNr0VQol1wuNxQVTRkVNUCGZc7vD29cDZkFzjDnnPl+\n/hJm5j3PwyDPPO/M+76CKIoiiIiISBE0tg6AiIiIzMfCTUREpCAs3ERERArCwk1ERKQgLNxEREQK\nwsJNRESkICzcRBIIDQ3FqVOnyr7ev38/oqOj8eyzz2LAgAGYNGkSfv/990c+Njw8HHfv3jX7WkeO\nHEFgYCDCw8MRHh6OsLAwREZG4uDBg2X3mTlzJg4dOgQA+PDDD9GjRw/Exsbi7Nmz6N27NyIiIpCd\nnV3JbM03ZswY3Lp1q9z3U1JSEBQUhPDwcDz77LMIDw9HVFQUfvnlF4uvMW7cOPz2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QNWrVoF4P6pdfn5+cjPz8fgwYMRHh6OTp06wdfXF5999lnZ4/7ci97S07na\ntWtX7rxjg8GA119/HXPnzi07tpOILMOpciI7ERgYiOPHj+PChQsAgISEBCxevBhZWVnQaDSIiYnB\nU089he+++w6lpaVVvl5kZCQOHjxYdtqcKIpISEjAzZs3WbSJqoAdN5Gd8PDwwMKFCzFp0iQYDAY0\nbNgQS5YsQe3ateHv749+/frhscceQ6dOnXD16lVJrrd27VosXrwYcXFxKC0tRdu2bbFy5UoJsiGy\nXzwdjIiISEHYcRORRdavX49t27aV+36DBg2wdu1aG0REZF/YcRMRESkIP5xGRESkICzcRERECsLC\nTUREpCAs3ERERArCwk1ERKQgLNxEREQK8v8FBNJP2m530QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x6d836208>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "    import matplotlib.pyplot as plt\n",
    "    import numpy as np\n",
    "    import matplotlib.pyplot as plt\n",
    "\n",
    "    fig, ax = plt.subplots()\n",
    "    N=10\n",
    "    ind = np.arange(N)  # the x locations for the groups\n",
    "    width = 0.3       # the width of the bars\n",
    "    # Example data\n",
    "    ind_name = tuple(monthly_ic_mean.index)\n",
    "    y_pos = np.arange(len(ind))\n",
    "    one_mean = monthly_ic_mean.iloc[:,0]\n",
    "    one_std = monthly_ic_std.iloc[:,0]\n",
    "    five_mean = monthly_ic_mean.iloc[:,1]\n",
    "    five_std = monthly_ic_std.iloc[:,1]\n",
    "    ten_mean = monthly_ic_mean.iloc[:,2]\n",
    "    ten_std = monthly_ic_std.iloc[:,2]\n",
    "\n",
    "    ax.barh(ind - width, one_mean, align='edge',height=0.2, xerr=one_std,\n",
    "            color='r', label='one_day')\n",
    "    ax.barh(ind - 0.05, five_mean, align='edge',height=0.2,xerr=five_std,\n",
    "            color='y', label='five_day')\n",
    "    ax.barh(ind + width, ten_mean, align='center',height=0.2,xerr=ten_std,\n",
    "            color='b', label='ten_day')\n",
    "\n",
    "    ax.set_yticks(y_pos)\n",
    "    ax.set_yticklabels(ind_name)\n",
    "#     ax.invert_yaxis()  # labels read top-to-bottom\n",
    "    ax.set_xlabel('mean_IC')\n",
    "    ax.set_title('IC in Different Period')\n",
    "    plt.legend()\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 如何用TA_Lib设计新的Alpha因子？\n",
    "加入slope技术指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                     000001.XSHE  000002.XSHE  000008.XSHE  000009.XSHE  \\\n",
      "datetime                                                                  \n",
      "2017-06-07 15:00:00     0.468032          NaN    -0.825076    -0.508490   \n",
      "2017-06-08 15:00:00     0.150155          NaN    -0.391822    -0.295820   \n",
      "2017-06-09 15:00:00    -0.166025          NaN    -0.356104    -0.475409   \n",
      "2017-06-12 15:00:00     0.001076          NaN    -0.311639    -0.243290   \n",
      "2017-06-13 15:00:00    -0.438850          NaN    -0.274481    -0.028803   \n",
      "\n",
      "                     000027.XSHE  000039.XSHE  000060.XSHE  000061.XSHE  \\\n",
      "datetime                                                                  \n",
      "2017-06-07 15:00:00    -0.527817    -0.964975    -0.730131    -0.581137   \n",
      "2017-06-08 15:00:00    -0.494012    -0.508576    -0.559069    -0.925861   \n",
      "2017-06-09 15:00:00    -0.382459     0.025234    -0.365330    -0.172980   \n",
      "2017-06-12 15:00:00    -0.256944     0.354929    -0.308335     0.580023   \n",
      "2017-06-13 15:00:00    -0.138483    -0.467419    -0.289608     0.247463   \n",
      "\n",
      "                     000063.XSHE  000069.XSHE     ...       601933.XSHG  \\\n",
      "datetime                                          ...                     \n",
      "2017-06-07 15:00:00    -0.682056    -0.150418     ...         -0.329169   \n",
      "2017-06-08 15:00:00    -1.398532    -0.572111     ...         -0.129520   \n",
      "2017-06-09 15:00:00    -0.849224    -0.428489     ...         -0.394047   \n",
      "2017-06-12 15:00:00    -1.372891    -0.764451     ...          0.180940   \n",
      "2017-06-13 15:00:00     0.586259     0.000161     ...          0.755829   \n",
      "\n",
      "                     601939.XSHG  601958.XSHG  601985.XSHG  601988.XSHG  \\\n",
      "datetime                                                                  \n",
      "2017-06-07 15:00:00     0.045057    -0.475734     0.342082     0.025351   \n",
      "2017-06-08 15:00:00    -0.171908     0.099668     0.162100    -0.106439   \n",
      "2017-06-09 15:00:00     0.021982     0.236086    -0.023458     0.206226   \n",
      "2017-06-12 15:00:00    -0.128668     0.282615    -0.211682     0.272712   \n",
      "2017-06-13 15:00:00    -0.287439     0.322012    -0.398876     0.096387   \n",
      "\n",
      "                     601989.XSHG  601998.XSHG  603000.XSHG  603885.XSHG  \\\n",
      "datetime                                                                  \n",
      "2017-06-07 15:00:00          NaN    -0.075819    -0.708276    -0.675892   \n",
      "2017-06-08 15:00:00          NaN    -0.363187     0.407481    -0.081584   \n",
      "2017-06-09 15:00:00          NaN    -0.252770     0.647606     0.645220   \n",
      "2017-06-12 15:00:00          NaN    -0.144400     0.717213     1.174633   \n",
      "2017-06-13 15:00:00          NaN     0.301515    -0.093011     0.599558   \n",
      "\n",
      "                     603993.XSHG  \n",
      "datetime                          \n",
      "2017-06-07 15:00:00     0.020607  \n",
      "2017-06-08 15:00:00    -0.184985  \n",
      "2017-06-09 15:00:00    -0.395304  \n",
      "2017-06-12 15:00:00    -0.607805  \n",
      "2017-06-13 15:00:00    -0.551658  \n",
      "\n",
      "[5 rows x 300 columns]\n"
     ]
    }
   ],
   "source": [
    "import talib as ta\n",
    "import numpy as np\n",
    "\n",
    "def slope(df, period=10):\n",
    "    return pd.DataFrame(\n",
    "        {name: ta.LINEARREG_SLOPE(item.values, period) for name, item in df.iteritems()},\n",
    "        index=df.index\n",
    "        )\n",
    "\n",
    "class alphas(object):\n",
    "    def __init__(self, pn_data):\n",
    "        self.close = pd.DataFrame(pn_data.minor_xs('close'), \n",
    "                                  dtype=np.float64)\n",
    "\n",
    "# 自制因子\n",
    "    def slope001(self):\n",
    "        alpha = -1 * slope(self.close)\n",
    "        return alpha\n",
    "\n",
    "print alphas(PN).slope001().tail(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读取五号因子选中的股票池"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "asset               000001.XSHE 000002.XSHE 000008.XSHE 000009.XSHE  \\\n",
      "date                                                                  \n",
      "2013-01-30 15:00:00       False       False       False       False   \n",
      "2013-01-31 15:00:00       False       False       False       False   \n",
      "2013-02-01 15:00:00       False       False       False       False   \n",
      "2013-02-04 15:00:00       False       False       False       False   \n",
      "2013-02-05 15:00:00       False       False       False       False   \n",
      "2013-02-06 15:00:00       False       False       False       False   \n",
      "2013-02-07 15:00:00       False       False       False       False   \n",
      "2013-02-08 15:00:00        True       False       False        True   \n",
      "2013-02-18 15:00:00       False       False       False        True   \n",
      "2013-02-19 15:00:00        True       False       False       False   \n",
      "2013-02-20 15:00:00        True       False       False       False   \n",
      "2013-02-21 15:00:00        True       False       False       False   \n",
      "2013-02-22 15:00:00        True       False       False       False   \n",
      "2013-02-25 15:00:00       False        True       False       False   \n",
      "2013-02-26 15:00:00       False        True       False       False   \n",
      "2013-02-27 15:00:00       False       False       False       False   \n",
      "2013-02-28 15:00:00       False       False       False       False   \n",
      "2013-03-01 15:00:00       False       False       False       False   \n",
      "2013-03-04 15:00:00       False        True       False       False   \n",
      "2013-03-05 15:00:00       False        True       False       False   \n",
      "2013-03-06 15:00:00       False       False       False       False   \n",
      "2013-03-07 15:00:00       False       False       False       False   \n",
      "2013-03-08 15:00:00       False       False       False       False   \n",
      "2013-03-11 15:00:00       False       False       False       False   \n",
      "2013-03-12 15:00:00       False       False       False       False   \n",
      "2013-03-13 15:00:00       False       False       False       False   \n",
      "2013-03-14 15:00:00       False       False       False       False   \n",
      "2013-03-15 15:00:00       False        True       False       False   \n",
      "2013-03-18 15:00:00       False       False       False       False   \n",
      "2013-03-19 15:00:00       False       False       False       False   \n",
      "...                         ...         ...         ...         ...   \n",
      "2017-04-14 15:00:00       False       False       False       False   \n",
      "2017-04-17 15:00:00       False        True       False       False   \n",
      "2017-04-18 15:00:00       False        True       False       False   \n",
      "2017-04-19 15:00:00       False       False       False       False   \n",
      "2017-04-20 15:00:00       False       False       False       False   \n",
      "2017-04-21 15:00:00       False       False       False       False   \n",
      "2017-04-24 15:00:00       False       False       False       False   \n",
      "2017-04-25 15:00:00       False       False       False       False   \n",
      "2017-04-26 15:00:00       False        True       False       False   \n",
      "2017-04-27 15:00:00       False        True       False       False   \n",
      "2017-04-28 15:00:00       False        True       False       False   \n",
      "2017-05-02 15:00:00       False        True       False       False   \n",
      "2017-05-03 15:00:00       False        True       False       False   \n",
      "2017-05-04 15:00:00       False        True       False       False   \n",
      "2017-05-05 15:00:00       False        True       False       False   \n",
      "2017-05-08 15:00:00       False        True       False       False   \n",
      "2017-05-09 15:00:00       False       False       False       False   \n",
      "2017-05-10 15:00:00       False       False       False       False   \n",
      "2017-05-11 15:00:00       False       False       False       False   \n",
      "2017-05-12 15:00:00       False       False       False       False   \n",
      "2017-05-15 15:00:00       False       False       False       False   \n",
      "2017-05-16 15:00:00       False        True       False       False   \n",
      "2017-05-17 15:00:00       False       False       False       False   \n",
      "2017-05-18 15:00:00       False       False       False       False   \n",
      "2017-05-19 15:00:00       False       False       False       False   \n",
      "2017-05-22 15:00:00       False       False       False       False   \n",
      "2017-05-23 15:00:00       False       False       False       False   \n",
      "2017-05-24 15:00:00       False       False       False       False   \n",
      "2017-05-25 15:00:00       False       False       False        True   \n",
      "2017-05-26 15:00:00       False       False       False        True   \n",
      "\n",
      "asset               000027.XSHE 000039.XSHE 000060.XSHE 000061.XSHE  \\\n",
      "date                                                                  \n",
      "2013-01-30 15:00:00       False       False       False       False   \n",
      "2013-01-31 15:00:00       False       False       False       False   \n",
      "2013-02-01 15:00:00       False       False       False       False   \n",
      "2013-02-04 15:00:00       False       False       False       False   \n",
      "2013-02-05 15:00:00       False        True       False       False   \n",
      "2013-02-06 15:00:00       False        True       False       False   \n",
      "2013-02-07 15:00:00       False       False       False       False   \n",
      "2013-02-08 15:00:00       False       False       False       False   \n",
      "2013-02-18 15:00:00       False       False       False       False   \n",
      "2013-02-19 15:00:00       False        True       False       False   \n",
      "2013-02-20 15:00:00       False       False       False       False   \n",
      "2013-02-21 15:00:00       False       False        True       False   \n",
      "2013-02-22 15:00:00       False        True        True       False   \n",
      "2013-02-25 15:00:00       False        True        True       False   \n",
      "2013-02-26 15:00:00       False        True        True       False   \n",
      "2013-02-27 15:00:00       False        True        True       False   \n",
      "2013-02-28 15:00:00       False        True        True       False   \n",
      "2013-03-01 15:00:00       False        True        True       False   \n",
      "2013-03-04 15:00:00       False        True        True       False   \n",
      "2013-03-05 15:00:00       False       False        True       False   \n",
      "2013-03-06 15:00:00       False       False        True       False   \n",
      "2013-03-07 15:00:00       False       False        True       False   \n",
      "2013-03-08 15:00:00       False       False        True       False   \n",
      "2013-03-11 15:00:00       False        True       False       False   \n",
      "2013-03-12 15:00:00       False       False       False       False   \n",
      "2013-03-13 15:00:00       False       False       False       False   \n",
      "2013-03-14 15:00:00       False        True       False       False   \n",
      "2013-03-15 15:00:00       False        True       False        True   \n",
      "2013-03-18 15:00:00       False        True       False       False   \n",
      "2013-03-19 15:00:00       False        True       False       False   \n",
      "...                         ...         ...         ...         ...   \n",
      "2017-04-14 15:00:00       False       False       False       False   \n",
      "2017-04-17 15:00:00       False       False       False       False   \n",
      "2017-04-18 15:00:00       False       False       False       False   \n",
      "2017-04-19 15:00:00       False       False       False       False   \n",
      "2017-04-20 15:00:00       False       False       False       False   \n",
      "2017-04-21 15:00:00       False       False       False       False   \n",
      "2017-04-24 15:00:00       False        True       False       False   \n",
      "2017-04-25 15:00:00       False       False       False        True   \n",
      "2017-04-26 15:00:00       False        True       False        True   \n",
      "2017-04-27 15:00:00       False        True       False        True   \n",
      "2017-04-28 15:00:00       False       False       False        True   \n",
      "2017-05-02 15:00:00       False        True       False        True   \n",
      "2017-05-03 15:00:00       False        True       False        True   \n",
      "2017-05-04 15:00:00       False        True       False        True   \n",
      "2017-05-05 15:00:00       False        True       False        True   \n",
      "2017-05-08 15:00:00       False        True       False       False   \n",
      "2017-05-09 15:00:00       False       False       False       False   \n",
      "2017-05-10 15:00:00       False        True       False       False   \n",
      "2017-05-11 15:00:00       False       False       False       False   \n",
      "2017-05-12 15:00:00       False       False       False       False   \n",
      "2017-05-15 15:00:00       False        True       False       False   \n",
      "2017-05-16 15:00:00       False       False       False       False   \n",
      "2017-05-17 15:00:00       False       False       False       False   \n",
      "2017-05-18 15:00:00       False       False       False       False   \n",
      "2017-05-19 15:00:00       False       False       False       False   \n",
      "2017-05-22 15:00:00       False       False       False       False   \n",
      "2017-05-23 15:00:00       False       False       False       False   \n",
      "2017-05-24 15:00:00       False       False       False       False   \n",
      "2017-05-25 15:00:00       False       False       False       False   \n",
      "2017-05-26 15:00:00       False       False       False       False   \n",
      "\n",
      "asset               000063.XSHE 000069.XSHE     ...     601933.XSHG  \\\n",
      "date                                            ...                   \n",
      "2013-01-30 15:00:00       False       False     ...           False   \n",
      "2013-01-31 15:00:00       False       False     ...           False   \n",
      "2013-02-01 15:00:00       False        True     ...           False   \n",
      "2013-02-04 15:00:00       False        True     ...           False   \n",
      "2013-02-05 15:00:00        True        True     ...           False   \n",
      "2013-02-06 15:00:00        True        True     ...           False   \n",
      "2013-02-07 15:00:00        True       False     ...           False   \n",
      "2013-02-08 15:00:00        True       False     ...           False   \n",
      "2013-02-18 15:00:00       False       False     ...           False   \n",
      "2013-02-19 15:00:00       False       False     ...           False   \n",
      "2013-02-20 15:00:00       False       False     ...           False   \n",
      "2013-02-21 15:00:00       False       False     ...           False   \n",
      "2013-02-22 15:00:00       False       False     ...           False   \n",
      "2013-02-25 15:00:00       False       False     ...           False   \n",
      "2013-02-26 15:00:00       False       False     ...           False   \n",
      "2013-02-27 15:00:00        True       False     ...           False   \n",
      "2013-02-28 15:00:00        True       False     ...           False   \n",
      "2013-03-01 15:00:00        True       False     ...           False   \n",
      "2013-03-04 15:00:00        True        True     ...           False   \n",
      "2013-03-05 15:00:00       False        True     ...           False   \n",
      "2013-03-06 15:00:00       False        True     ...           False   \n",
      "2013-03-07 15:00:00       False        True     ...           False   \n",
      "2013-03-08 15:00:00       False        True     ...           False   \n",
      "2013-03-11 15:00:00       False       False     ...           False   \n",
      "2013-03-12 15:00:00       False       False     ...           False   \n",
      "2013-03-13 15:00:00       False       False     ...           False   \n",
      "2013-03-14 15:00:00       False       False     ...           False   \n",
      "2013-03-15 15:00:00       False       False     ...           False   \n",
      "2013-03-18 15:00:00       False       False     ...           False   \n",
      "2013-03-19 15:00:00       False       False     ...           False   \n",
      "...                         ...         ...     ...             ...   \n",
      "2017-04-14 15:00:00       False       False     ...           False   \n",
      "2017-04-17 15:00:00       False       False     ...           False   \n",
      "2017-04-18 15:00:00       False       False     ...           False   \n",
      "2017-04-19 15:00:00       False       False     ...           False   \n",
      "2017-04-20 15:00:00       False       False     ...           False   \n",
      "2017-04-21 15:00:00       False       False     ...           False   \n",
      "2017-04-24 15:00:00       False       False     ...           False   \n",
      "2017-04-25 15:00:00       False       False     ...           False   \n",
      "2017-04-26 15:00:00       False       False     ...           False   \n",
      "2017-04-27 15:00:00       False       False     ...           False   \n",
      "2017-04-28 15:00:00       False       False     ...           False   \n",
      "2017-05-02 15:00:00       False       False     ...           False   \n",
      "2017-05-03 15:00:00       False       False     ...           False   \n",
      "2017-05-04 15:00:00       False       False     ...           False   \n",
      "2017-05-05 15:00:00       False       False     ...           False   \n",
      "2017-05-08 15:00:00       False       False     ...           False   \n",
      "2017-05-09 15:00:00       False       False     ...           False   \n",
      "2017-05-10 15:00:00       False       False     ...           False   \n",
      "2017-05-11 15:00:00       False       False     ...           False   \n",
      "2017-05-12 15:00:00       False       False     ...           False   \n",
      "2017-05-15 15:00:00       False       False     ...           False   \n",
      "2017-05-16 15:00:00       False       False     ...           False   \n",
      "2017-05-17 15:00:00       False       False     ...           False   \n",
      "2017-05-18 15:00:00       False       False     ...           False   \n",
      "2017-05-19 15:00:00       False       False     ...           False   \n",
      "2017-05-22 15:00:00       False       False     ...           False   \n",
      "2017-05-23 15:00:00       False       False     ...           False   \n",
      "2017-05-24 15:00:00       False       False     ...           False   \n",
      "2017-05-25 15:00:00       False       False     ...           False   \n",
      "2017-05-26 15:00:00       False       False     ...           False   \n",
      "\n",
      "asset               601939.XSHG 601958.XSHG 601985.XSHG 601988.XSHG  \\\n",
      "date                                                                  \n",
      "2013-01-30 15:00:00       False       False       False       False   \n",
      "2013-01-31 15:00:00       False       False       False       False   \n",
      "2013-02-01 15:00:00       False        True       False       False   \n",
      "2013-02-04 15:00:00       False       False       False       False   \n",
      "2013-02-05 15:00:00       False       False       False       False   \n",
      "2013-02-06 15:00:00       False       False       False       False   \n",
      "2013-02-07 15:00:00       False        True       False       False   \n",
      "2013-02-08 15:00:00       False       False       False       False   \n",
      "2013-02-18 15:00:00       False       False       False       False   \n",
      "2013-02-19 15:00:00       False        True       False       False   \n",
      "2013-02-20 15:00:00       False        True       False       False   \n",
      "2013-02-21 15:00:00       False        True       False       False   \n",
      "2013-02-22 15:00:00       False        True       False       False   \n",
      "2013-02-25 15:00:00       False        True       False       False   \n",
      "2013-02-26 15:00:00       False        True       False       False   \n",
      "2013-02-27 15:00:00       False        True       False       False   \n",
      "2013-02-28 15:00:00       False        True       False       False   \n",
      "2013-03-01 15:00:00       False        True       False       False   \n",
      "2013-03-04 15:00:00       False        True       False       False   \n",
      "2013-03-05 15:00:00       False        True       False       False   \n",
      "2013-03-06 15:00:00       False        True       False       False   \n",
      "2013-03-07 15:00:00       False        True       False       False   \n",
      "2013-03-08 15:00:00       False       False       False       False   \n",
      "2013-03-11 15:00:00       False       False       False       False   \n",
      "2013-03-12 15:00:00       False       False       False       False   \n",
      "2013-03-13 15:00:00       False       False       False       False   \n",
      "2013-03-14 15:00:00       False       False       False       False   \n",
      "2013-03-15 15:00:00       False       False       False       False   \n",
      "2013-03-18 15:00:00       False       False       False       False   \n",
      "2013-03-19 15:00:00       False       False       False       False   \n",
      "...                         ...         ...         ...         ...   \n",
      "2017-04-14 15:00:00       False       False       False       False   \n",
      "2017-04-17 15:00:00       False       False       False       False   \n",
      "2017-04-18 15:00:00       False       False       False       False   \n",
      "2017-04-19 15:00:00       False       False       False       False   \n",
      "2017-04-20 15:00:00       False       False       False       False   \n",
      "2017-04-21 15:00:00       False       False       False       False   \n",
      "2017-04-24 15:00:00       False       False       False       False   \n",
      "2017-04-25 15:00:00       False       False       False       False   \n",
      "2017-04-26 15:00:00       False       False       False       False   \n",
      "2017-04-27 15:00:00       False       False       False       False   \n",
      "2017-04-28 15:00:00       False       False       False       False   \n",
      "2017-05-02 15:00:00       False       False       False       False   \n",
      "2017-05-03 15:00:00       False       False       False       False   \n",
      "2017-05-04 15:00:00       False       False       False       False   \n",
      "2017-05-05 15:00:00       False       False       False       False   \n",
      "2017-05-08 15:00:00       False       False       False       False   \n",
      "2017-05-09 15:00:00       False       False       False       False   \n",
      "2017-05-10 15:00:00       False       False       False       False   \n",
      "2017-05-11 15:00:00       False       False       False       False   \n",
      "2017-05-12 15:00:00       False       False       False       False   \n",
      "2017-05-15 15:00:00       False       False       False       False   \n",
      "2017-05-16 15:00:00       False       False       False       False   \n",
      "2017-05-17 15:00:00       False       False       False       False   \n",
      "2017-05-18 15:00:00       False       False       False       False   \n",
      "2017-05-19 15:00:00       False       False       False       False   \n",
      "2017-05-22 15:00:00       False       False       False       False   \n",
      "2017-05-23 15:00:00       False       False       False       False   \n",
      "2017-05-24 15:00:00       False       False       False       False   \n",
      "2017-05-25 15:00:00       False       False       False       False   \n",
      "2017-05-26 15:00:00       False       False       False       False   \n",
      "\n",
      "asset               601989.XSHG 601998.XSHG 603000.XSHG 603885.XSHG  \\\n",
      "date                                                                  \n",
      "2013-01-30 15:00:00       False       False       False       False   \n",
      "2013-01-31 15:00:00       False       False       False       False   \n",
      "2013-02-01 15:00:00       False       False       False       False   \n",
      "2013-02-04 15:00:00       False       False        True       False   \n",
      "2013-02-05 15:00:00       False       False       False       False   \n",
      "2013-02-06 15:00:00       False       False       False       False   \n",
      "2013-02-07 15:00:00       False       False       False       False   \n",
      "2013-02-08 15:00:00       False       False       False       False   \n",
      "2013-02-18 15:00:00       False        True       False       False   \n",
      "2013-02-19 15:00:00       False        True       False       False   \n",
      "2013-02-20 15:00:00       False        True       False       False   \n",
      "2013-02-21 15:00:00       False       False       False       False   \n",
      "2013-02-22 15:00:00       False       False       False       False   \n",
      "2013-02-25 15:00:00       False       False       False       False   \n",
      "2013-02-26 15:00:00       False       False       False       False   \n",
      "2013-02-27 15:00:00       False       False       False       False   \n",
      "2013-02-28 15:00:00       False       False       False       False   \n",
      "2013-03-01 15:00:00       False       False       False       False   \n",
      "2013-03-04 15:00:00       False       False       False       False   \n",
      "2013-03-05 15:00:00       False       False       False       False   \n",
      "2013-03-06 15:00:00       False       False       False       False   \n",
      "2013-03-07 15:00:00       False       False       False       False   \n",
      "2013-03-08 15:00:00       False       False        True       False   \n",
      "2013-03-11 15:00:00       False       False        True       False   \n",
      "2013-03-12 15:00:00       False       False        True       False   \n",
      "2013-03-13 15:00:00       False       False       False       False   \n",
      "2013-03-14 15:00:00       False       False        True       False   \n",
      "2013-03-15 15:00:00       False       False        True       False   \n",
      "2013-03-18 15:00:00       False       False        True       False   \n",
      "2013-03-19 15:00:00       False       False       False       False   \n",
      "...                         ...         ...         ...         ...   \n",
      "2017-04-14 15:00:00       False       False       False       False   \n",
      "2017-04-17 15:00:00       False       False        True        True   \n",
      "2017-04-18 15:00:00       False       False       False        True   \n",
      "2017-04-19 15:00:00       False       False        True       False   \n",
      "2017-04-20 15:00:00       False       False       False        True   \n",
      "2017-04-21 15:00:00       False       False        True       False   \n",
      "2017-04-24 15:00:00       False       False        True       False   \n",
      "2017-04-25 15:00:00       False       False        True       False   \n",
      "2017-04-26 15:00:00       False       False        True       False   \n",
      "2017-04-27 15:00:00       False       False        True       False   \n",
      "2017-04-28 15:00:00       False       False        True       False   \n",
      "2017-05-02 15:00:00       False       False        True       False   \n",
      "2017-05-03 15:00:00       False       False       False       False   \n",
      "2017-05-04 15:00:00       False       False        True       False   \n",
      "2017-05-05 15:00:00       False       False        True       False   \n",
      "2017-05-08 15:00:00       False       False        True       False   \n",
      "2017-05-09 15:00:00       False       False       False       False   \n",
      "2017-05-10 15:00:00       False       False       False       False   \n",
      "2017-05-11 15:00:00       False       False       False       False   \n",
      "2017-05-12 15:00:00       False       False        True        True   \n",
      "2017-05-15 15:00:00       False       False       False       False   \n",
      "2017-05-16 15:00:00       False       False        True        True   \n",
      "2017-05-17 15:00:00       False       False       False       False   \n",
      "2017-05-18 15:00:00       False       False       False        True   \n",
      "2017-05-19 15:00:00       False       False        True        True   \n",
      "2017-05-22 15:00:00       False       False        True        True   \n",
      "2017-05-23 15:00:00       False       False        True        True   \n",
      "2017-05-24 15:00:00       False       False       False       False   \n",
      "2017-05-25 15:00:00       False       False        True       False   \n",
      "2017-05-26 15:00:00       False       False       False       False   \n",
      "\n",
      "asset               603993.XSHG  \n",
      "date                             \n",
      "2013-01-30 15:00:00       False  \n",
      "2013-01-31 15:00:00       False  \n",
      "2013-02-01 15:00:00       False  \n",
      "2013-02-04 15:00:00       False  \n",
      "2013-02-05 15:00:00       False  \n",
      "2013-02-06 15:00:00       False  \n",
      "2013-02-07 15:00:00       False  \n",
      "2013-02-08 15:00:00       False  \n",
      "2013-02-18 15:00:00       False  \n",
      "2013-02-19 15:00:00       False  \n",
      "2013-02-20 15:00:00       False  \n",
      "2013-02-21 15:00:00       False  \n",
      "2013-02-22 15:00:00       False  \n",
      "2013-02-25 15:00:00       False  \n",
      "2013-02-26 15:00:00       False  \n",
      "2013-02-27 15:00:00       False  \n",
      "2013-02-28 15:00:00       False  \n",
      "2013-03-01 15:00:00       False  \n",
      "2013-03-04 15:00:00       False  \n",
      "2013-03-05 15:00:00       False  \n",
      "2013-03-06 15:00:00       False  \n",
      "2013-03-07 15:00:00       False  \n",
      "2013-03-08 15:00:00       False  \n",
      "2013-03-11 15:00:00       False  \n",
      "2013-03-12 15:00:00       False  \n",
      "2013-03-13 15:00:00       False  \n",
      "2013-03-14 15:00:00       False  \n",
      "2013-03-15 15:00:00       False  \n",
      "2013-03-18 15:00:00       False  \n",
      "2013-03-19 15:00:00       False  \n",
      "...                         ...  \n",
      "2017-04-14 15:00:00       False  \n",
      "2017-04-17 15:00:00       False  \n",
      "2017-04-18 15:00:00       False  \n",
      "2017-04-19 15:00:00       False  \n",
      "2017-04-20 15:00:00       False  \n",
      "2017-04-21 15:00:00       False  \n",
      "2017-04-24 15:00:00       False  \n",
      "2017-04-25 15:00:00       False  \n",
      "2017-04-26 15:00:00       False  \n",
      "2017-04-27 15:00:00       False  \n",
      "2017-04-28 15:00:00       False  \n",
      "2017-05-02 15:00:00       False  \n",
      "2017-05-03 15:00:00       False  \n",
      "2017-05-04 15:00:00       False  \n",
      "2017-05-05 15:00:00       False  \n",
      "2017-05-08 15:00:00       False  \n",
      "2017-05-09 15:00:00       False  \n",
      "2017-05-10 15:00:00       False  \n",
      "2017-05-11 15:00:00       False  \n",
      "2017-05-12 15:00:00       False  \n",
      "2017-05-15 15:00:00       False  \n",
      "2017-05-16 15:00:00       False  \n",
      "2017-05-17 15:00:00       False  \n",
      "2017-05-18 15:00:00       False  \n",
      "2017-05-19 15:00:00       False  \n",
      "2017-05-22 15:00:00       False  \n",
      "2017-05-23 15:00:00       False  \n",
      "2017-05-24 15:00:00       False  \n",
      "2017-05-25 15:00:00       False  \n",
      "2017-05-26 15:00:00       False  \n",
      "\n",
      "[1049 rows x 300 columns]\n"
     ]
    }
   ],
   "source": [
    "factor_005 = alpha.alpha005().stack()\n",
    "\n",
    "factor_data = alphalens.utils.get_clean_factor_and_forward_returns(factor_005, prices, quantiles=5)\n",
    "\n",
    "# print factor_data\n",
    "\n",
    "cond = factor_data['factor_quantile'] == 5\n",
    "Q5 = factor_data[cond]\n",
    "stocks = pd.Series(True, index=Q5.index)\n",
    "stocks = stocks.unstack()\n",
    "stocks[stocks != True] = False\n",
    "print(stocks)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作业\n",
    "下载Alpha101.pdf研究，并设计有效的Alpha因子，柱形图展示绩效，最后输出股票池Excel。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
